package com.lzh.runke.controller;

import com.lzh.runke.entity.Coffee;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

/**
 * @author LiuZiHao
 * @date 创建时间:2023年06月14日 09:51:24
 */
@RestController
@RequestMapping("/test")
public class TestController {

    private static final LocalDateTime FIXED_DATE = LocalDateTime.now();

    /**
     * 默认情况
     * {
     * "name": null,
     * "brand": "商",
     * "date": [
     * 2023,
     * 6,
     * 14,
     * 10,
     * 9,
     * 52,
     * 814000000
     * ]
     * }
     * <p>
     * 我们希望排除null值并自定义日期格式
     *
     * @param brand
     * @param name
     * @return
     */
    @GetMapping("/coffee")
    public Coffee getCoffee(
            @RequestParam(required = false) String brand,
            @RequestParam(required = false) String enumValue,
            @RequestParam(required = false) String name) {
        return Coffee.builder().name(name).brand(brand).date(FIXED_DATE).waterPeriodEnum(enumValue).build();
    }

}
